/* 员工管理相关接口 */
import request from '@/utils/request'

// 1.获取员工简单列表
export const reqGetEmployeeSimple = () => {
  return request.get('/sys/user/simple')
}

// 2.获取员工综合列表
export const reqGetEmployeeList = (page, size) => {
  return request({
    method: 'get',
    url: '/sys/user',
    params: { page, size },
  })
}

// 3.删除员工
export const reqDelEmployeeById = id => {
  return request({
    method: 'delete',
    url: `/sys/user/${id}`,
  })
}

// 4.新增员工
export const reqAddEmployee = data => {
  return request({
    method: 'post',
    url: '/sys/user',
    data,
  })
}

// 5.批量导入员工
export const reqImportEmployee = data => {
  return request({
    method: 'POST',
    url: '/sys/user/batch',
    data,
  })
}

// 6.更新用户名密码
export const reqUpdateUserDetail = data => {
  return request({
    method: 'put',
    url: `/sys/user/${data.id}`,
    data,
  })
}

// 7.获取员工个人信息(用户详情的基础信息)
export const reqGetPersonalInfo = id => {
  return request.get(`/employees/${id}/personalInfo`)
}

// 8.更新员工个人信息(用户详情的基础信息)
export const reqUpdatePersonalInfo = data => {
  return request({
    method: 'put',
    url: `/employees/${data.userId}/personalInfo`,
    data,
  })
}

// 9.获取员工岗位信息(用户的岗位信息)
export const reqGetJobInfo = id => {
  return request.get(`/employees/${id}/jobs`)
}

// 10.更新员工岗位信息(用户的岗位信息)
export const reqUpdateJobInfo = data => {
  return request({
    method: 'put',
    url: `/employees/${data.userId}/jobs`,
    data,
  })
}

// 11.给员工分配角色
export const reqEditAssignRoles = (id, roleIds) => {
  return request({
    method: 'put',
    url: '/sys/user/assignRoles',
    data: { id, roleIds },
  })
}
